<?php
session_start();
include("UserIncludes/DbConfig.php");
// if($_REQUEST['del']=="del" && isset($_REQUEST['did']) && isset($_REQUEST['field']))
// {
// mysql_query("update document_master set ".$_REQUEST['field']."='' where documentId='".$_REQUEST['did']."'");
// if($_REQUEST['type']!='')
// {
// $dd="&type=".$_REQUEST['type'];
// }
// else
// {
// $dd='';
// }
// header("location:filedetails.php?id=".$_REQUEST['did'].$dd);
// }
if(isset($_POST['uploadevent']) && $_POST['uploadevent']=='1')
{
	//echo "<script>alert('hi634')</script>";
	//echo "1111";die();
    include("watermark_funpast.php");
	$ftmp = $_FILES['image']['tmp_name'];
	
	$a=rand(1,200000);
	$ex=explode(".",$_FILES['image']['name']);
	$file_ex=count($ex);
	$oname="event_".date("ymdhms").$a.".".$ex[$file_ex-1];
//echo "<script>alert('".$oname."')</script>";
	//$_SESSION['image_name']=$oname;
//echo "<script>alert('".$_SESSION['image_name']."')</script>";
	
	$extenssion = strstr($oname, ".");
	$fname = 'upload_mobile_image/'.$oname;

		if(move_uploaded_file($ftmp, $fname)){
	watermark_funpast($oname,'upload_mobile_image','upload_mobile_image_thumb','100','100');
	watermark_funpast($oname,'upload_mobile_image','upload_mobile_image','600','650');
		
    $thumb_='upload_mobile_image/'.$oname;
	$val_name="imagefile";
$fieldnaem="imageLoc".$_REQUEST['imgnum'];
 mysql_query("insert into temp_image_upload set image_name ='".$oname."', user_id = '".$_SESSION['siteuserId']."'");
// echo "==================="."update document_master set $fieldnaem='".$oname."' where documentId='".$_REQUEST['documentid']."'";die();

?>
 			<html><head><link href="css/new_global.css" rel="stylesheet" type="text/css">
 			<script language="javascript">
			var urlto='http://www.esolz.org/admobweb_new/';
			var par = window.parent.document;
			var images = par.getElementById('preview');
			//images.innerHTML='<img src="upload_mobile_image_thumb/<?php echo $oname; ?>" alt="abcdef">';
			images.innerHTML='<div class=thirdNavTabs><table border=0 align=left cellpadding=0 cellspacing=0><tr><td id=Nav1 onclick=show_mobile_set(1)><img src="images/admob-SButton.jpg" alt="" width="29" height="22" /></td><td width="3">&nbsp;</td><td id=Nav2 onclick=show_mobile_set(2)><img src="images/admob-MButton.jpg" alt="" width="29" height="22" /></td><td width="3">&nbsp;</td><td id=Nav3 onclick=show_mobile_set(3)><img src="images/admob-LButton.jpg" alt="" width="29" height="22" /></td><td width="3">&nbsp;</td><td id=Nav4 onclick=show_mobile_set(4)><img src="images/admob-XLButton.jpg" alt="" width="29" height="22" /></td><td width="3">&nbsp;</td></tr></table><div class=x-clear></div></div><tr><td width="3">&nbsp;</td></tr><div id=content_1><img src="upload_mobile_image_thumb/<?php echo $oname; ?>" alt="abcdef" width="120" height="20"></div><div id=content_2 style=display:none><img src="upload_mobile_image_thumb/<?php echo $oname; ?>" alt="abcdef" width="168" height="28"></div><div id=content_3 style=display:none><img src="upload_mobile_image_thumb/<?php echo $oname; ?>" alt="abcdef" width="216" height="36"></div><div id=content_4 style=display:none><img src="upload_mobile_image_thumb/<?php echo $oname; ?>" alt="abcdef" width="300" height="50"></div>';
			//alert(images);
			//var imgdiv = images.getElementsByTagName('div')[<?php// echo (int)$_POST['imgnum']?>];
			//var image = imgdiv.getElementsByTagName('img')[0];
			//alert(image);
			///////////////////////////////////
			//imgdiv.removeChild(image);
			//imgdiv.id='div_<?php echo (int)$_POST['imgnum']?>';
			var image_new = par.createElement('img');
			//alert(image_new);
			image_new.src = '<?php echo $thumb_;?>';
			//alert(image_new.src);
			//image_new.className = 'loaded';
			//imgdiv.appendChild(image_new);
			//var bre	=	par.createElement('br');
			//imgdiv.appendChild(bre);
			var myLink1 = par.createElement('a');
			myLink1.href = "upload.php?del=del&did=<?php echo $_REQUEST['documentid']?>&field=<?php echo $_REQUEST['field'];?>&type=<?php echo $_REQUEST['type'];?>";
			myLink1.className = "blacklink";
			myLink1.onclick=function(e){
			var par_r= window.parent.document;
			var images_r = par_r.getElementById('preview');
			var urlto1='http://www.esolz.org/admobweb_new/';
		    //var imgdiv_r = par_r.getElementById('div_<?php// echo (int)$_POST['imgnum']?>');
           // var imgna_r = par_r.getElementById('firstField_<?php// echo (int)$_POST['imgnum']?>');
        	//images_r.removeChild(imgdiv_r);
			//images_r.removeChild(imgna_r);
			/////////////////////////////////////
	    	var imgdiv_r_len1 = images_r.getElementsByTagName('div').length;
	        if(imgdiv_r_len1==3)
			{
			var new_iframe = par.createElement('iframe');
	        new_iframe.src = 'upload.php';
	        new_iframe.frameBorder = '0';
			new_iframe.scrolling='no';
			new_iframe.width='600';
			new_iframe.height='50';
	       // par.getElementById('iframe1').appendChild(new_iframe);
			}
			////////////////////////////////////
			}
			myLink1.appendChild(par.createTextNode('Remove'));
			imgdiv.appendChild(myLink1);
			//////////////////////////////////////////////
			var newInput1 = par.createElement("input");
            newInput1.setAttribute('type','hidden');
            newInput1.setAttribute('name','imagefile[]');
            newInput1.setAttribute('id','firstField_<?php echo (int)$_POST['imgnum']?>');
            newInput1.setAttribute('value','<?php echo $oname;?>');
            images.appendChild(newInput1);
			/////////////////////////////////////////////////
			var oNewP = par.createElement('span');
			var oText = par.createTextNode("  ");
			  oNewP.appendChild(oText);
			  imgdiv.appendChild(oNewP);
			</script></head>
 			</html>
 			<?php
			//exit();
			
		}	
		}
?><html><head>
<script language="javascript">

function upload(){
//alert('hi');
var url='http://www.esolz.org/admobweb_new/';
var fcheck=document.iform.image.value;
if(fcheck.lastIndexOf(".jpg")==-1 && fcheck.lastIndexOf(".jpeg")==-1 && fcheck.lastIndexOf(".JPG")==-1 && fcheck.lastIndexOf(".JPEG")==-1 &&fcheck.lastIndexOf(".png")==-1 && fcheck.lastIndexOf(".PNG")==-1  && fcheck.lastIndexOf(".gif")==-1 && fcheck.lastIndexOf(".GIF")==-1)
{
alert("Please Upload jpg,gif,png format Image");
return false;
}
	var par = window.parent.document;
	var num = 1 - 1;
	var iframe = par.getElementsByTagName('iframe')[num];
	iframe.className = 'hidden';
	var images = par.getElementById('preview');
	var new_div = par.createElement('div');
	        var new_img = par.createElement('img');
            var imgnum_n = images.getElementsByTagName('div').length;	
            new_div.id='div_'+1;
	        new_img.src = 'images/indicator.gif';
	        new_img.className = 'load';
	      	//var imgnum = document.iform.imgnum.value;
// 	if(imgnum<3)
// 			{
// 	// create new iframe
// 	var new_iframe = par.createElement('iframe');
// 	new_iframe.src = 'upload.php';
// 	new_iframe.frameBorder = '0';
// 	new_iframe.scrolling='no';
// 	new_iframe.width='400';
// 	new_iframe.height='50';
// 	
// 	//par.getElementById('iframe1').appendChild(new_iframe);
// 	}
	//alert("hi123");
	document.iform.submit();

}

function show_mobile_set(id)
{
	alert(id);
	for(var i =1; i<=4;i++)
	{
// 		if(document.getElementById('content_'+i))
// 		{
			if(i == id)
			{
				//alert('aaa');
				document.getElementById('content_'+i).style.display = 'block';	
			}
			else
			{
				document.getElementById('content_'+i).style.display = 'none';	
			}

		//}
		
	}
	
}
</script>
<style>
#file {
	width: 350px;
}
</style>
<head><body bgcolor="#f8f9fb">

<span id="countdiv">
<form name="iform" action="" method="post" enctype="multipart/form-data">
	<table align="center" width="100%" bgcolor="" cellpadding="1" cellspacing="1" border="0">	
	<tr>
		<td align="left" valign="top" colspan="2" class="heading" style="font:Verdana; font-size:14px; font-weight:600;"><!--<font color="#000000">Upload new Image</font>--></td>
	</tr>

<tr >
		<td align="left" valign="top" width="60%" style="font:Verdana; font-size:11px; font-weight:600;"><font color="#000000">Browse an Image</font></td>
		<td align="right" valign="top"><input id="file" type="file" name="image" onChange="upload()"> </td>
	</tr>

	</table>
		<input type="hidden" name="imgnum"  id="imgnum" value="<?php echo $_REQUEST['id'];?>"/>
		<!--<input type="hidden" name="documentid"  id="documentid" value="<?php// echo $_REQUEST['documentid'];?>"/><input type="hidden" name="field"  id="field" value="<?php// echo $_REQUEST['field'];?>"/><input type="hidden" name="type"  id="type" value="<?php// echo $_REQUEST['type'];?>"/>-->
		<input type="hidden" name="uploadevent" value="1">
</form>	
</span>
</html>